<template>
  <div>
    <Echart
      :options="options"
      id="centreLeft1Chart"
      height="3.1rem"
      width="100%"
    ></Echart>
  </div>
</template>

<script>
import Echart from '@/common/echart'
export default {
  data () {
    return {
      options: {
         xAxis: {
            type: 'category',
            min: 0,
            data: []
          },
          yAxis: {
            type: 'value',
            min: 0,
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'cross',
              label: {
                backgroundColor: '#49FDDF'
              }
            }
          },
          series: [
            {
              data: [],
              type: 'line',
              smooth: true,
              lineStyle: {
                normal: {
                  color: {
                      type: "linear",
                      x: 0,
                      y: 0,
                      x2: 1,
                      y2: 0,
                      colorStops: [
                        {
                          offset: 0,
                          color: "#1c98e8"
                        },
                        {
                          offset: 1,
                          color: "#28f8de"
                        }
                      ]

                  },
                  width: 3
                }
              },
              areaStyle: {
                normal: {
                  color: {
                      type: "linear",
                      x: 0,
                      y: 0,
                      x2: 1,
                      y2: 0,
                      colorStops: [
                        {
                          offset: 0,
                          color: "#1c98e8"
                        },
                        {
                          offset: 1,
                          color: "#28f8de"
                        }
                      ]

                  },
                }
              },

            }
          ]
      },
      
    };
  },
  components: {
    Echart,
  },
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    },
  },
  watch: {
    cdata: {
      handler(val) {
        // console.log("监听",val);
        this.options.series[0].data = val.barData;
        this.options.xAxis.data = val.category;
      },
      deep: true,
    },
  },
};
</script>